import java.awt.List;
import java.util.LinkedList;

import play.test.*;
import models.*;


import org.junit.*;

import controllers.Board;
import play.test.UnitTest;
public class testDeleteBoard extends UnitTest{

	@Test
	public void DeleteBoard(){
		Project j=new Project("tesssst","test", true).save();
		EventType t=new EventType("sprint").save();
		
    	Event e=new Event("Cool test",t ).save();
    	e.project=j;
    	e.save();
    	
    	TaskStatus s=new TaskStatus("test").save();
    	BoardColumn c=new BoardColumn(2, s, "ahmed", null, null).save();
    	LinkedList<BoardColumn> col=new LinkedList();
    	col.add(c);
    	VirtualBoard v=new VirtualBoard(e, "project",col).save();
    	assertNotNull(VirtualBoard.findById(v.getEntityId()));
    	
    	Board.deleteBoards(((Long)j.getEntityId()).longValue());
    	Event ev=Event.findById(e.getEntityId());
    	assertNull(ev.board);
    	
	}
	@Test
	public void DeleteSnap(){
		Project j=new Project("tesssst","test", true).save();
		EventType t=new EventType("sprint").save();
		
    	Event e=new Event("Cool test",t ).save();
    	e.project=j;
    	e.save();
    	j.events = new LinkedList();
    	j.events.add(e);
    	j.save();
    	e.Snapshots=new LinkedList();
    	Snapshot n=new Snapshot("salma","mmmmm");
    	Snapshot n2=new Snapshot("jjhsalma","mmmmms");
    	e.Snapshots.add(n);
    	e.Snapshots.add(n2);
    	
    	e.save();
    	Event testout=Event.findById(e.getEntityId());
    	assertFalse((testout.Snapshots).isEmpty());
    	Board.deleteSnapshots(j.id);
    	testout=Event.findById(e.getEntityId());
    	assertNull(testout.Snapshots);
    	
	}
}